package GUI;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import Listeners.AccessConferenceListener;

import Model.Conference;
import Model.ConferenceManager;

/**
 * Class used for constructing JPanels containing
 * important conference information and buttons for
 * accessing the conference.
 * 
 * @author Paul Schultz (ps87@uw.edu)
 * @version 11/30/2012
 */
@SuppressWarnings("serial")
public class ConferencePanel extends JPanel
{
  
  /**
   * Constructs Conference Panel.
   * 
   * @param the_conf The conference to be represented by the panel.
   * @param the_manager The ConferenceManger containing the conference.
   * @param the_frame Reference to master frame of application.
   */
  public ConferencePanel(final Conference the_conf, 
      final ConferenceManager the_manager, final ConferenceWizardFrame the_frame)
  {
    super();
    this.setAlignmentX(LEFT_ALIGNMENT);
    GridLayout gLayout = new GridLayout(0,2);
    //gLayout.setVgap(5);
    this.setLayout(gLayout);
    JLabel titleLabel = new JLabel("Name: " + the_conf.conferenceName());
    titleLabel.setFont(new Font("Plain", Font.PLAIN, 18));
    //titleLabel.setAlignmentX(LEFT_ALIGNMENT);
    
    JLabel dateLabel = new JLabel("Submission Deadline: " 
        + the_conf.getDeadline().getMonth() + "/"
        + the_conf.getDeadline().getDate() + "/"
        + (1900 + the_conf.getDeadline().getYear()));
    dateLabel.setFont(new Font("Plain", Font.PLAIN, 16));
    dateLabel.setForeground(new Color(0, 0, 102));
    
    JLabel pcLabel = new JLabel("Program Chair: " 
        + the_conf.programChair().realName());
    pcLabel.setFont(new Font("Plain", Font.PLAIN, 16));
    pcLabel.setForeground(new Color(0, 0, 102));
    
    JPanel pcPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    pcPanel.add(pcLabel);
    
    JPanel blank = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    JLabel spacer = new JLabel(" ");
    spacer.setFont(new Font("Plain", Font.PLAIN, 24));
    blank.add(spacer);
    
    JPanel button_panel = new JPanel();
    JButton select = new JButton("Select Conference");
    select.addActionListener(new AccessConferenceListener(the_conf, the_manager,the_frame));
    button_panel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    
    //button_panel.add(spacer);
    button_panel.add(select);
    
    this.add(titleLabel);
    this.add(button_panel);
    this.add(dateLabel);
    this.add(blank);
    this.add(pcPanel);
    
    //this.setPreferredSize();
    this.setMaximumSize(new Dimension(925, 80));
    this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    
  }
}
